< previous page page_68 next page >

Page 68
Example program LineTo, shown in Figure 2.4, compares the MoveToEx and LineTo functions with the Visual Basic's Line method. It fills two picture boxes with small line segments, one using the Line method and one using the MoveToEx and LineTo functions. In one set of tests on a 133MHz Pentium, drawing the lines using the Line method took more than three times as long.
Polygons and Polylines
The Polyline, Polygon, PolyPolyline, and PolyPolygon functions let you draw many line segments all at once. The following code shows the Visual Basic declarations for these functions.
e10a6a0a59f035e870d90cca05b85fce.gif
Private Type POINTAPI
    x As Long
    y As Long
End Type

Private Declare Function Polyline Lib "gdi32" _
    Alias "Polyline" (ByVal hdc As Long, _
    lpPoint As POINTAPI, ByVal nCount As Long) As Long

Private Declare Function Polygon Lib "gdi32" _
    Alias "Polygon" (ByVal hdc As Long, _
    lpPoint As POINTAPI, ByVal nCount As Long) As Long

Private Declare Function PolyPolyline Lib "gdi32" _
    Alias "PolyPolyline" (ByVal hdc As Long, _
    lppt As POINTAPI, lpdwPolyPoints As Long, _
    ByVal cCount As Long) As Long
0068-01.jpg
Figure 2.4
Example program LineTo compares the speeds of
Visual Basic's Line statement and the LineTo API function.

 
< previous page page_68 next page >